home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!ittpub!ittpub!nntp
- Newsgroups: comp.lang.c++
- Subject: Re: [Q]Dereference within class - Possible?
- Message-ID: <1996Mar13.130156.1804@ittpub>
- From: wil@ittpub.nl (Wil Evers)
- Date: 13 Mar 96 13:01:56 WET
- References: <Do566t.F1H.0.queen@torfree.net>
- Distribution: world
- Nntp-Posting-Host: lintilla
-
- In article <Do566t.F1H.0.queen@torfree.net> bh332@torfree.net (Karim
- Ladha) writes:
- > Greetings,
- >
- > In normal C style, one can code the following example(C++ compiler);
- >
- > int main() {
- > int x = 1;
- > int &x1 = x;
- > ...
- > }
- >
- > Is it also possible to use the same syntax within a class without
- > intializing the referencer? Any information will be appreciated...
-
- A reference is not a pointer. In particular, a reference must always refer
- to some object (there is no such thing as the NULL reference) and it
- cannot be changed to refer to some other object. This is why references
- must be initialized at the point where they come into existence. If you
- need more flexibility, you'll have to use pointers and live with their
- dangers.
-
- - Wil
-
-